package others;

import com.google.gson.GsonBuilder;

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class ReadLink {

    public static void main(String[] args) {
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create("https://gdgpo.czt.gd.gov.cn/gpcms/rest/web/v2/index/selectInfoByOpenTenderCode?channel=fca71be5-fc0c-45db-96af-f513e9abda9d&site=cd64e06a-21a7-4620-aebc-0576bab7e07a&openTenderCode=HZLT2025HY05032&_t=1752327160170"))
                .GET()
                .build();
        HttpClient client = HttpClient.newHttpClient();
        HttpResponse.BodyHandler<String> bodyHandler = HttpResponse.BodyHandlers.ofString();
        client.sendAsync(request, bodyHandler)
                .thenApply(HttpResponse::body)
                .thenApply(str -> {
                    return new GsonBuilder()
                            .create()
                            .fromJson(str, TenderResp.class);
                })
                .thenAccept(System.out::println)
                .join()
        ;
    }
}
